/**
 * @author
 * Júlio Zynger
 * DRE: 110092466
 */
package view;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import model.Estado;

@SuppressWarnings("serial")
public class Dialog extends JFrame {

	private JPanel contentPane;

	public Dialog(String message) {
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(400, 300, 400, 100);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		setTitle("Erro!");
		setResizable(false);
		
		JLabel lblTexto = new JLabel("Texto");
		lblTexto.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblTexto.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblTexto, BorderLayout.NORTH);
		
		lblTexto.setText(message);
		
		JButton btnOk = new JButton("Ok");
		contentPane.add(btnOk, BorderLayout.SOUTH);
		
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e1) {
				Dialog.this.dispose();
			}
		});
		
		this.setVisible(true);
	}
	
	/**
	 * @wbp.parser.constructor
	 */
	public Dialog(String message, ArrayList<Estado> sequenciaEstados, ArrayList<String> sequenciaConfig, Estado parei) {
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(400, 300, 500, 150);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		GridLayout gl_contentPane = new GridLayout(3, 1);
		gl_contentPane.setVgap(4);
		contentPane.setLayout(gl_contentPane);
		setContentPane(contentPane);
		
		setTitle("Erro!");
		setResizable(true);
		
		JLabel lblTexto = new JLabel("Texto");
		lblTexto.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblTexto.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblTexto);
		
		lblTexto.setText(message);
		
		JLabel lblNomeEstado = new JLabel("Texto");
		lblNomeEstado.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblNomeEstado.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblNomeEstado);
		
		String s;
		if(sequenciaEstados.size()>0){
			s = "( "+sequenciaEstados.get(0).getNome()+", "+sequenciaConfig.get(0)+" )";
			for (int i = 1; i < sequenciaConfig.size(); i++) {
				s += " Ⱶ ( "+sequenciaEstados.get(i).getNome()+", "+sequenciaConfig.get(i)+" )";
			}
			s += " Ⱶ (" + parei.getNome() + ", ε )";
		}else s = "(" + parei.getNome() + ", ε )";
		
		
		
		lblNomeEstado.setText(s);//"Parei no estado "+ estadoDoFim);		
		
		JButton btnOk = new JButton("Ok");
		contentPane.add(btnOk);
		
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e1) {
				Dialog.this.dispose();
			}
		});
		
		this.setVisible(true);
	}

}
